<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
    <script type="text/javascript">
        var Human=function(param){
            this.skills=param&&param.slills||'保密';
            this.hobby=param&&param.hobby||'保密';

        }
        Human.prototype={
            getSkill:function(){
                return this.skills
            },
            getHobbyy:function(){
                return this.hobby
            }
        }

        var Name=function(name){
            var that=this;
            (function(name,that){
                that.wholeName=name;
                if(name.indexOf(" ")>-1){
                    that.firstName=name.slice(0,name.indexOf(" "))
                    that.secondName=name.slice(name.indexOf(" "))

                }
            })(name,that)
        }
        var Work=function(work){
            var that=this;
            (function(work,that){
                switch(work){
                    case 'code':
                    that.work='工程师';
                    that.workDesc='每天沉醉编程';
                    break;
                    case' UI':case 'UE':
                    that.work='设计师';
                    that.workDesc='每天沉醉编程';
                    break;
                    default:
                    that.work=work;
                    that.workDesc='null';
                }
            })(work,that)
        }
        Work.prototype.changeWork=function(work){
            this.work=work;
        }
        Work.prototype.workDesc=function(desc){
            this.workDesc=desc;
        }
        var Person=function(name,work){
            var person=new Human()
            person.name=new Name(name)
            person.work=new Work(work)
            return person;
        }
        var p1=new Person('liu fei','code')
        console.log(p1)
    </script>
    </body>
</html>